// 给定一个数组arr，和一个数num，把小于等于num的数放在数组的左边，大于的放在右边,等于的在中间
// 要求空间复杂度O(1)时间复杂度O(N)
const process = (arr: Array<number>,num: number) =>{
    let i = 0
    let p1 = 0
    let p2 = arr.length-1
    while(i != p2){
        if(arr[i] < num){
            swap(arr,i,p1)
            p1++
            i++
        }else if(arr[i] > num){
            swap(arr,i,p2)
            p2--
        }else{
            i++
        }
    }
}
const swap = function(arr: Array<number>,i: number,j: number) { 
    let num = 0
    num = arr[i] 
    arr[i] = arr[j]
    arr[j] = num
}
let arr = [3,7,4,2,7,8,23,5,7]
process(arr,5)
console.log(arr)
export default process